<template>
  <div>
    <div class="tabs-bar">
      <van-tabs v-model="active">
        <van-tab title="完工报告"></van-tab>
        <van-tab title="纸质版完工报告"></van-tab>
      </van-tabs>
    </div>
    <div v-show="active === 0">
      <van-list v-model="loading" :finished="finished" finished-text="没有更多了" @load="onLoad">
        <van-cell v-for="(item,index) in reportList" :key="index" @click="toReportInfo(index,item.id)">
          <span>{{item.KKScode}}</span>
          <br />
          <span>{{item.description}}</span>
          <br />
          <span>{{item.leader}}</span>
        </van-cell>
      </van-list>
    </div>
    <div v-show="active === 1">
      <van-list v-model="loading" :finished="finished" finished-text="没有更多了" @load="onLoad">
        <van-cell
          v-for="(item,index) in paperReportList"
          :key="index"
          @click="toPaperReportInfo(index,item.id)"
        >
          <span>{{item.KKScode}}</span>
          <br />
          <span>{{item.description}}</span>
          <br />
          <span>{{item.leader}}</span>
        </van-cell>
      </van-list>
    </div>
  </div>
</template>
<script>
import { getReportList, getPaperReportList } from "@/api/data";
export default {
  data() {
    return {
      reportList: [],
      paperReportList: [],
      active: 0,
      loading: false,
      finished: false
    };
  },
  methods: {
    onLoad() {
      Promise.all([getReportList(), getPaperReportList()])
        .then(res => {
          console.log(res);
          this.loading = false;
          window.reportList = this.reportList = res[0].data;
          window.paperReportList = this.paperReportList = res[1].data;
          this.finished = true;
        })
        .catch(e => {
          this.$toast("请求错误");
        });
    },
    toReportInfo(index,id) {
       this.$router.push({name:"ReportInfo",params:{index:index,id:id}});
    },
    toPaperReportInfo(index,id) {
       this.$router.push({name:"PaperReportInfo",params:{index:index,id:id}});
    }
  }
};
</script>

